package com.vaasplus.bms.model.enums;

import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * 设备类型
 */
@Getter
public enum DeviceType {

    /**
     * 自营设备
     */
    SELF_DEVICE((short) 0, "Self-employed"),

    /**
     * 国标设备，设备自注册添加
     */
    GB_DEVICE((short) 1, "GB"),

    /**
     * 云南雪亮工程 千里眼
     */
    @Deprecated
    QLY_DEVICE((short) 2, "QLY"),

    /**
     * 国标设备，用户添加
     */
    GB_DEVICE_MANUAL((short) 3, "GB_M"),
    ;

    private final Short code;

    private final String value;

    DeviceType(Short code, String value) {
        this.code = code;
        this.value = value;
    }

    public static DeviceType acquireByCode(final Short code) {
        return Arrays.stream(DeviceType.values())
                .filter(e -> Objects.equals(e.code, code))
                .findFirst().orElseThrow(() -> new UnsupportedOperationException(
                        "this DeviceType can not support : " + code));
    }

}
